<!-- topbar starts -->
	<div id="header" class="navbar">
		<div class="navbar-inner">
			<div class="container-fluid">
				<a class="btn btn-navbar" data-toggle="collapse" data-target=".top-nav.nav-collapse,.sidebar-nav.nav-collapse">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</a>
				<a class="brand" href="{{Router::url('/')}}"> <span>Miao CMS</span></a>
    							
				<!-- user dropdown starts -->
				<div class="btn-group pull-right" >
					<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
						<span class="icon icon-color icon-user"></span><span class="hidden-phone">{{$this->Session->read('Auth.Staff.name')}}</span>
						<span class="caret"></span>
					</a>
					<ul class="dropdown-menu">
						<li><a href="#">{{__('Profile')}}</a></li>
						<li class="divider"></li>
						<li>{{$this->Html->link(__('Default Mode'), '/?theme=default')}}</li>
						<li>{{$this->Html->link(__('Desktop Mode'), '/?theme=desktop')}}</li>
						<li>{{$this->Html->link(__("File Manage"), '/admin/ace/editors/index')}}</li>
						<li class="divider"></li>
						{{loop $selectlans $lan $native}}        	 
          <li>
          {{if defined('APPEND_LOCALE_BASE')}}
          	{{if $lan=='zh-cn'}}<a href="{{Router::url('/../')}}">{{$native}}</a> {{else}}	<a href="{{Router::url('/../'.$lan)}}">{{$native}}</a>{{/if}}
          {{else}}
            {{if $lan=='zh-cn'}}<a href="{{Router::url('/')}}">{{$native}}</a>{{else}}<a href="{{Router::url('/'.$lan)}}">{{$native}}</a>{{/if}}
          {{/if}}
          </li>
          {{/loop}}
						<li class="divider"></li>
						<li><a href="{{Router::url('/admin/staffs/logout')}}">{{__('Logout')}}</a></li>
					</ul>
				</div>
				<!-- user dropdown ends -->
				
				<div class="top-nav nav-collapse">
					
					{{$this->Section->getNavMenu('Menu',array(
						'selectedid'=> $top_category_id,
						'preli'=>'',
						'maxdepth' => 1,
						'sufli'=>'',
					),1,false)}}
					<ul class="nav">
						<li>
				  	{{if defined('APPEND_LOCALE_BASE')}}
				  		{{$this->Html->link(__('Visit website'), '/../../',array('target'=>'_blank'))}}
				    {{else}}
				        {{$this->Html->link(__('Visit website'), '/../',array('target'=>'_blank'))}}
				    {{/if}}
				  	</li>
						<li>
							<form class="navbar-search pull-left">
								<input placeholder="Search" class="search-query span2" name="query" type="text">
							</form>
						</li>
					</ul>
				</div><!--/.nav-collapse -->
			</div>
		</div>
	</div>
	<!-- topbar ends -->
	<script>
	$(function(){
		
		$('#leftmenucontent').find('a').addClass('ajax-link');
		
		$("#header .nav-pills a").bind('click',function(e){
			/*切换菜单*/
			var ref = $(this).attr('ref');
			$('#header .nav-pills').find('.active').removeClass('active');
			$(this).blur().parent('li:first').addClass('active');
			$('#leftmenucontent').find('.leftmenu').hide();
			$('#leftmenucontent').find('#leftmenu_'+ref).show();
			e.preventDefault();
			
			/*点击时，打开子菜单的第一项对应的页面*/
			var obj = $('#leftmenucontent').find('#leftmenu_'+ref).find('.nav a').eq(0);
			if(obj.attr('href').substr(0,1)=='#'){
				return false;
			}
			else if(obj.attr('rel')=='ajaxAction'){
				ajaxAction(obj.attr('href'));
				return false;
			}
			else if(obj.attr('href').match(/javascript:/) || typeof(obj.attr('onclick'))!='undefined'){
				obj.trigger('click');
				return false;
			}
			else{
				History.pushState(null, null, obj.attr('href'));
				obj.parent('ul').removeClass('active');
				obj.parent('li').addClass('active');	
			}
			return false;
		});
		$('#leftmenucontent').find('a').click(function(){
			if($(this).attr('rel')=='ajaxAction'){
				ajaxAction($(this).attr('href'));
				return false;
			}				
		});
		
	})	
	</script>